﻿using System.Diagnostics;
using System.IO;
using System.Text;

namespace common
{
    public class bianyi_net : bianyi
    {
        public override void work(string sPath)
        {
            string usesoft = Path.GetFullPath(strGreen + "\\development server\\10.0");
            string soft = Path.GetFullPath(strGreen + "\\development server\\2.bat");
            string dir = Path.GetDirectoryName(sPath);
            string driver = Directory.GetDirectoryRoot(sPath);
            driver = driver.Replace("\\", "");
            string file = Path.GetFileName(sPath);
            string fileWithoutExtension = Path.GetFileNameWithoutExtension(sPath);
            string filepath = Path.Combine(dir, file);
            string port = ParseXml.get_net_run_port();

            Encoding encode = Encoding.Default;

            StreamReader sr = new StreamReader(soft);
            string temp = sr.ReadToEnd();
            temp = temp.Replace("$soft", usesoft);
            temp = temp.Replace("$driver", driver);
            temp = temp.Replace("$path", sPath);
            temp = temp.Replace("$port", port);

            StreamWriter sw = new StreamWriter(strGreen + "\\development server\\temp.bat", false, encode);
            sw.Write(temp);
            sw.Flush();
            sw.Close();

            Process.Start(strGreen + "\\development server\\temp.bat");
        }
    }
}